const LOGIN_STATUS_KEY = 'isLoggedIn';
const REDIRECT_FILM_ID_KEY = 'redirectFilmId';

module.exports = {
  // 检查用户是否登录
  checkLoginStatus: function () {
    const token = wx.getStorageSync('token');
    return !!token;
  },

  // 设置用户登录状态
  login: function () {
    wx.setStorageSync(LOGIN_STATUS_KEY, true);
  },

  // 清除用户登录状态
  logout: function () {
    wx.removeStorageSync(LOGIN_STATUS_KEY);
  },

  // 保存需要重定向的电影ID
  setRedirectFilmId: function (filmId) {
    wx.setStorageSync(REDIRECT_FILM_ID_KEY, filmId);
  },

  // 获取并清除需要重定向的电影ID
  getAndClearRedirectFilmId: function () {
    const filmId = wx.getStorageSync(REDIRECT_FILM_ID_KEY);
    wx.removeStorageSync(REDIRECT_FILM_ID_KEY);
    return filmId;
  }
}; 